<?xml version="1.0" encoding="utf-8" ?>
<!--

//***************************************************************************
// ***** Script Header *****
//
// Solution:  Solution Accelerator for Business Desktop Deployment
// File:      _template_ENU.xml
//
// Purpose:   BDD Welcome Wizard
//
// Microsoft Solution Version:  2.6.0
// Microsoft Script Version:    2.6.0
// Customer Build Version:      1.0.0
// Customer Script Version:     1.0.0
//
// Microsoft History:
// 2.6.0    KeithGa  03/14/2006  New Template Version!
//
// Customer History:
//
// ***** End Header *****
//***************************************************************************

-->
<Wizard>
  <Global>

    <!-- Global commands are executed when this *.xml file is loaded for the first time, 
         Before any pages are loaded. -->

    <!-- Collection of one or more Statments to be loaded with the VBScript ExecuteGlobal command -->
      <CustomStatement>
      <![CDATA[ 
      
option explicit
         
document.title =  "Welcome Windows Deployment"         
window.resizeTo 500,500
window.moveTo Window.screen.width/2 - 500/2, Window.screen.height/2 - 500/2

Dim SelectedDivItem
Dim SelectedIcon

function MouseOut(element)
      element.style.backgroundColor = "Transparent"   
   if not isempty(SelectedDivItem) then
      if element is SelectedDivItem then
         element.style.backgroundColor = "#F0F0F0"  
      end if
   end if
end function 

function ItemHasBeenSelected(Command,Icon,DivItem)

   ' Clear Previous
   
   if not isempty(SelectedIcon) then
      SelectedIcon.src = "Whiteness.jpg"   
   end if 
   
   if not isempty(SelectedDivItem) then
      SelectedDivItem.style.backgroundColor = "Transparent"   
   end if 

   set SelectedDivItem = DivItem
   set SelectedIcon = Icon

   WelcomeWizardCommand.Value = Command
   buttonNext.disabled = false
   SelectedDivItem.style.backgroundColor = "#F0F0F0" 
   SelectedIcon.src = "SelectItem.jpg"
   
end function 

Function SafeRegRead( KeyValue )
   on error resume next
      SafeRegRead = oShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinPE\KeyboardLayouts\" & GetLocale & "\" & KeyValue)
   on error goto 0
end function 

Function GetKeyboardLocale

   GetKeyboardLocale = hex(GetLocale)   
   while len(GetKeyboardLocale) < 4
      GetKeyboardLocale = "0" & GetKeyboardLocale
   wend
   GetKeyboardLocale = GetKeyboardLocale & ":0000" & GetKeyboardLocale

end function 


function WelcomeWizard_CustomInitialization 

    dim sName, sID, i, j, Insert, oOption, KeyboardLocale
    dim FoundPrimary
    
    FoundPrimary = False
    
    ItemHasBeenSelected "DeployWizard",Button1, Row1    
    
    if not oFso.FileExists("x:\sources\recovery\RecEnv.exe") then
       Row2.Style.display = "none"
       Button2.Style.display = "none"
    end if

    ' Test for the 1st registry entry
    if isempty(SafeRegRead( "0\Name" )) then
       ' Not Found, run WpeUtil again
       oShell.Run "wpeutil.exe ListKeyboardLayout " & GetLocale, 0, TRUE
    end if
    
    if isempty(SafeRegRead( "0\Name" )) or isempty(SafeRegRead( "0\ID" ))then
       ' Still not found, some kind of problem with wpeutil.exe
       oLogging.CreateEntry "Could not enumerate Keyboard list through WPEUtil.exe", LogTypeWarning              
    end if
    
    KeyboardLocale = oEnvironment.Item("KeyboardLocale")
    if KeyboardLocale = "" then
        KeyboardLocale = hex(GetLocale)   
        while len(KeyboardLocale) < 4
            KeyboardLocale = "0" & KeyboardLocale
        wend
        KeyboardLocale = KeyboardLocale & ":0000" & KeyboardLocale
    end if

    i = 0 
    sName = SafeRegRead( i & "\Name" )
    sID = SafeRegRead( i & "\ID" )
    do while not isempty(sName) and not isempty(sID)
    
        Insert = -1  ' Default
    
        for j = 0 to WinPEKeyboard.options.length - 1
            if StrComp(sName,WinPEKeyboard.Options(j).Text,VbTextCompare) < 0 then
               Insert = j 
               exit For
            end if            
        next

        ' Skip if pre-existing
        for j = 0 to WinPEKeyboard.options.length - 1
            if WinPEKeyboard.options(j).value = sID then            
                WinPEKeyboard.options(j).Selected = sID = KeyboardLocale
                Insert = empty
                exit for
            end if            
        next
        
        ' Add entry to the display.
        if not isempty(Insert) then
            set oOption = document.CreateElement("OPTION")
            
            if ucase(sID) = ucase(KeyboardLocale) then
                FoundPrimary = True
                oOption.Selected = True                
            elseif FoundPrimary = False and ucase(right(sID,8)) = ucase(right(KeyboardLocale,8)) then
                oOption.Selected = True                
            end if 
            oOption.text = sName
            oOption.Value = sID
            WinPEKeyboard.Add oOption, Insert
        end if

        i = i + 1
        sName = SafeRegRead( i & "\Name" )
          sID = SafeRegRead( i & "\ID" )
    loop
    
end function 

function ConfigureStaticIP
    oShell.run "MSHTA.exe " & oUtility.ScriptDir & "\Wizard.hta /definition:NICSettings_Definition_ENU.xml"
end function 

      ]]> 
    </CustomStatement>

  </Global>

  <!-- ************************************************************** -->
  <!-- ************************************************************** -->
  
  <!-- Each page is defined within a PANE element. -->
  <Pane id="Ready">

      <ButtonNext>
          <Label>
              <![CDATA[
           <!-- This is the default Behaviour -->
           <button accesskey=N id=buttonNext language=vbscript onclick=ButtonNextClick><U>N</U>ext</button>
        ]]>
          </Label>
      </ButtonNext>

      <!-- If ButtonCancel is defined, it will override the default behaviour for this button -->
      <ButtonCancel>
          <Label>
              <![CDATA[
           <!-- This is the default Behaviour -->
           <button accesskey=R id=buttonCancel language=vbscript onclick=window.close><U>R</U>eboot</button-->
        ]]>
          </Label>
      </ButtonCancel>

      <Initialization><![CDATA[ WelcomeWizard_CustomInitialization ]]> </Initialization>


      <!-- All Content here is displayed to the body of the window. -->
      <Body>
          <![CDATA[

           <!-- Use the H1 Style for titles at the top of the page -->
           <H1>Welcome to Deployment<H1>
           
           <br/>
           
           <table width=70% cellspacing=0 cellpadding=0>           
           
              <tr onclick="javascript:ItemHasBeenSelected('DeployWizard',Button1, Row1);" >
                 <td><IMG id=Button1 SRC=Whiteness.jpg></td>
                 <td ID=Row1 onMouseOver="javascript:Row1.style.backgroundColor = '#ccffff';" 
                          onMouseOut="javascript:MouseOut(Row1);" >                 
                     <div style="font-size: larger;">&nbsp;&nbsp;&nbsp;Run the Deployment Wizard<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to install a new operating system.</div>                        </td>
              </tr>
              
              <tr><td>&nbsp;</td></tr>
           
              <tr onclick="javascript:ItemHasBeenSelected('Recovery',Button2, Row2);" >
                 <td><IMG id=Button2 SRC=Whiteness.jpg></td>
                 <td id=Row2  onMouseOver="javascript:Row2.style.backgroundColor = '#ccffff';" 
                          onMouseOut="javascript:MouseOut(Row2);" >                 
                     <div style="font-size: larger;">&nbsp;&nbsp;&nbsp;Run the recovery console.</div>                 
                 </td>
              </tr>

              <tr><td>&nbsp;</td></tr>

              <tr onclick="javascript:ItemHasBeenSelected('CommandPrompt',Button3, Row3);" >
                 <td><IMG id=Button3 SRC=Whiteness.jpg></td>
                 <td id=Row3 onMouseOver="javascript:Row3.style.backgroundColor = '#ccffff';" 
                          onMouseOut="javascript:MouseOut(Row3);" >                 
                     <div style="font-size: larger;">&nbsp;&nbsp;&nbsp;Exit to command Prompt.</div>                 
                 </td>
              </tr>

           </Table>
           
           <p>&nbsp;</p>

           <p>Keyboard Layout</br>
               <select id=WinPEKeyboard Name=KeyboardLocale class=WideEdit >
                   <option value="0409:00000409">United States</option>
               </select>
           </p>
           
           <input type=hidden Name=WelcomeWizardCommand />

           </br>
           <div class=WideEdit align=center>
              <input type=button value="Configure with Static IP Address..." onclick="configureStaticIP" />
           </div>           

        ]]>
      
    </Body>


  </Pane>
  
  <!-- ************************************************************** -->
  <!-- ************************************************************** -->

</Wizard>
